Protocol flow for notarizing a transaction

ABSTRACT

A method and system are provided to support a decentralized distributed ledger in which transactions are recorded by parties to the transactions without the use of a blockchain. A distributed ledger system provides a protocol framework that supports the development of protocol flows. A protocol flow is computer code that controls the performance of a transaction by the party or parties to the transaction. Protocol flows can be developed for different types of transactions. The distributed ledger system allows transactions to be proposed, accepted, and notarized by a notary and stored without the use of a blockchain ledger. The distributed ledger system can avoid the expense of the computational and storage resources needed to redundantly verify a transaction and store evidence on the many nodes of a blockchain distributed ledger.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation of U.S. patent application Ser. No.16/680,055, filed on Nov. 11, 2019, entitled “PROTOCOL FLOW FORNOTARIZING A TRANSACTION”, which is a divisional of U.S. patentapplication Ser. No. 15/364,213, filed on Nov. 29, 2016 entitled “SECUREPROCESSING OF ELECTRONIC TRANSACTIONS BY A DECENTRALIZED DISTRIBUTEDLEDGER SYSTEM”, which claims the benefit of U.S. Provisional ApplicationNo. 62/427,685, filed on Nov. 29, 2016 entitled “CORDA: A DISTRIBUTEDLEDGER”, and claims priority to U.S. patent application Ser. No.15/243,902 entitled “SYSTEM AND METHOD FOR MANAGING TRANSACTIONS INDYNAMIC DIGITAL DOCUMENTS”, Ser. No. 15/243,473 entitled “SYSTEM ANDMETHOD FOR MANAGING TRANSACTIONS IN DYNAMIC DIGITAL DOCUMENTS”, and Ser.No. 15/243,402 entitled “SYSTEM AND METHOD FOR MANAGING TRANSACTIONS INDYNAMIC DIGITAL DOCUMENTS”, all filed on Aug. 22, 2016, which all claimthe benefit of U.S. Provisional Application No. 62/323,952 entitled“SYSTEM AND METHOD FOR MANAGING TRANSACTIONS IN DYNAMIC DIGITALDOCUMENTS”, filed on Apr. 18, 2016; all of which are hereby incorporatedby reference in their entirety.

BACKGROUND

The bitcoin system was developed to allow electronic cash to betransferred directly from one party to another without going through afinancial institution, as described in the white paper entitled“Bitcoin: A Peer-to-Peer Electronic Cash System” by Satoshi Nakamoto. Abitcoin (e.g., an electronic coin) is represented by a chain oftransactions that transfers ownership from one party to another party.To transfer ownership of a bitcoin, a new transaction is generated andadded to a stack of transactions in a block. The new transaction, whichincludes the public key of the new owner, is digitally signed by theowner with the owner's private key to transfer ownership to the newowner as represented by the new owner public key. Once the block isfull, the block is “capped” with a block header that is a hash digest ofall the transaction identifiers within the block. The block header isrecorded as the first transaction in the next block in the chain,creating a mathematical hierarchy called a “blockchain.” To verify thecurrent owner, the blockchain of transactions can be followed to verifyeach transaction from the first transaction to the last transaction. Thenew owner need only have the private key that matches the public key ofthe transaction that transferred the bitcoin. The blockchain creates amathematical proof of ownership in an entity represented by a securityidentity (e.g., a public key), which in the case of the bitcoin systemis pseudo-anonymous.

To ensure that a previous owner of a bitcoin did not double-spend thebitcoin (i.e., transfer ownership of the same bitcoin to two parties),the bitcoin system maintains a distributed ledger of transactions. Withthe distributed ledger, a ledger of all the transactions for a bitcoinis stored redundantly at multiple nodes (i.e., computers) of ablockchain network. The ledger at each node is stored as a blockchain.In a blockchain, the transactions are stored in the order that thetransactions are received by the nodes. Each node in the blockchainnetwork has a complete replica of the entire blockchain. The bitcoinsystem also implements techniques to ensure that each node will storethe identical blockchain, even though nodes may receive transactions indifferent orderings. To verify that the transactions in a ledger storedat a node are correct, the blocks in the blockchain can be accessed fromoldest to newest, generating a new hash of the block and comparing thenew hash to the hash generated when the block was created. If the hashesare the same, then the transactions in the block are verified. Thebitcoin system also implements techniques to ensure that it would beinfeasible to change a transaction and regenerate the blockchain byemploying a computationally expensive technique to generate a nonce thatis added to the block when it is created. A bitcoin ledger is sometimesreferred to as an Unspent Transaction Output (“UXTO”) set because ittracks the output of all transactions that have not yet been spent.

Although the bitcoin system has been very successful, it is limited totransactions in bitcoins or other cryptocurrencies. Efforts arecurrently underway to use blockchains to support transactions of anytype, such as those relating to the sale of vehicles, sale of financialderivatives, sale of stock, payments on contracts, and so on. Suchtransactions use identity tokens, which are also referred to as digitalbearer bonds, to uniquely identify something that can be owned or canown other things. An identity token for a physical or digital asset isgenerated using a cryptographic one-way hash of information thatuniquely identifies the asset. Tokens also have an owner that uses anadditional public/private key pair. The owner public key is set as thetoken owner identity and when performing actions against tokens,ownership proof is established by providing a signature generated by theowner private key and validated against the public key listed as theowner of the token. A person can be uniquely identified, for example,using a combination of a user name, social security number, andbiometric (e.g., fingerprint). A product (e.g., refrigerator) can beuniquely identified, for example, using the name of its manufacturer andits seral number. The identity tokens for each would be a cryptographicone-way hash of such combinations. The identity token for an entity(e.g., person or company) may be the public key of a public/private keypair, where the private key is held by the entity. Identity tokens canbe used to identify people, institutions, commodities, contracts,computer code, equities, derivatives, bonds, insurance, loans,documents, and so on. Identity tokens can also be used to identifycollections of assets. An identity token for a collection may be acryptographic one-way hash of the digital tokens of the assets in thecollection. The creation of an identity token for an asset in ablockchain establishes provenance of the asset, and the identity tokencan be used in transactions (e.g., buying, selling, insuring) of theasset stored in a blockchain, creating a full audit trail of thetransactions.

To record a simple transaction in a blockchain, each party and assetinvolved with the transaction needs an account that is identified by adigital token. For example, when one person wants to transfer a car toanother person, the current owner and next owner create accounts, andthe current owner also creates an account that is uniquely identified byits vehicle identification number. The account for the car identifiesthe current owner. The current owner creates a transaction against theaccount for the car that indicates that the transaction is a transfer ofownership transfer, indicates the public keys (i.e., identity tokens) ofthe current owner and the next owner, and indicates the identity tokenof the car. The transaction is signed by the private key of the currentowner and the transaction is evidence that the next owner is now thecurrent owner.

To enable more complex transactions than bitcoin can support, somesystems use “smart contracts.” A smart contract is computer code thatimplements transactions of a contract. The computer code may be executedin a secure platform (e.g., an Ethereum platform, which provides avirtual machine) that supports recording transactions in blockchains. Inaddition, the smart contract itself is recorded as a transaction in theblockchain using an identity token that is a hash (i.e., identity token)of the computer code so that the computer code that is executed can beauthenticated. When deployed, a constructor of the smart contractexecutes, initializing the smart contract and its state. The state of asmart contract is stored persistently in the blockchain. When atransaction is recorded against a smart contract, a message is sent tothe smart contract, and the computer code of the smart contract executesto implement the transaction (e.g., debit a certain amount from thebalance of an account). The computer code ensures that all the terms ofthe contract are complied with before the transaction is recorded in theblockchain. For example, a smart contract may support the sale of anasset. The inputs to a smart contract to sell a car may be the identitytokens of the seller, the buyer, and the car and the sale price in U.S.dollars. The computer code ensures that the seller is the current ownerof the car and that the buyer has sufficient funds in their account. Thecomputer code then records a transaction that transfers the ownership ofthe car to the buyer and a transaction that transfers the sale pricefrom the buyer's account to the seller's account. If the seller'saccount is in U.S. dollars and the buyer's account is Canadian dollars,the computer code may retrieve a currency exchange rate, determine howmany Canadian dollars the seller's account should be debited, and recordthe exchange rate. If either transaction is not successful, neithertransaction is recorded.

When a message is sent to a smart contract to record a transaction, themessage is sent to each node that maintains a replica of the blockchain.Each node executes the computer code of the smart contract to implementthe transaction. For example, if 100 nodes each maintain a replica of ablockchain, then the computer code executes at each of the 100 nodes.When a node completes execution of the computer code, the result of thetransaction is recorded in the blockchain. The nodes employ a consensusalgorithm to decide on which transactions to keep and which transactionsto discard. Although the execution of the computer code at each nodehelps ensure the authenticity of the blockchain, it requires largeamounts of computer resources to support such redundant execution ofcomputer code.

The term “contract” has been used to describe the computer code of acontract under the UXTO model of bitcoin and the computer code of the“smart contracts” model of the Ethereum platform. The “contracts” underthese models are, however, different. In the UXTO model, the distributedledger is a set of immutable rows keyed by (hash: output index) values.The “hash” is a hash of the transaction that generated the outputrepresented by the row, and the “output index” identifies which one ofthe possibly many outputs of the transaction that the row represents. AUXTO contract is deterministic and performs no processing other thanvalidating the inputs to the transaction. In the “smart contract” model,the computer code of the smart contract is an instantiation of thecomputer code that is maintained by every node that stores the blockchain. A “smart contract” can perform virtually any type of processingsuch as receiving messages, sending messages, accessing externaldatabases, and so on.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram that illustrates an example a transaction in someembodiments.

FIG. 2 is a block diagram illustrating components of the distributedledger system in some embodiments.

FIG. 3 is a flow diagram illustrating processing of an example flow forthe role of an acceptor for a protocol flow in some embodiments.

FIG. 4 is a flow diagram that illustrates processing of an example flowfor the role of the proposer of the protocol flow of FIG. 3 in someembodiments.

FIG. 5 is a flow diagram that illustrates processing of a notary in someembodiments.

FIG. 6 is a flow diagram that illustrates processing of a create flowcomponent of the protocol framework in some embodiments.

FIG. 7 is a flow diagram that illustrates processing of a verifytransaction component of the protocol framework in some embodiments.

FIG. 8 is a flow diagram that illustrates processing of a resolvetransaction component of the protocol framework in some embodiments.

FIG. 9 is a flow diagram that illustrates processing of an executeverify function component of the framework protocol in some embodiments.

FIG. 10 is a flow diagram illustrating processing of a send messagecomponent of the protocol framework in some embodiments.

FIG. 11 is a flow diagram that illustrates processing of a receivemessage component of the protocol framework in some embodiments.

FIG. 12 is a flow diagram that illustrates processing of a rewritecontract code component in some embodiments.

FIG. 13 is a flow diagram that illustrates processing of a check forforbidden constructs component in some embodiments.

FIG. 14 is a flow diagram that illustrates processing of an instrumentexpensive bytecodes component in some embodiments.

FIG. 15 is a flow diagram that illustrates processing of a disabledforbidden exception catching component in some embodiments.

FIG. 16 is a flow diagram that illustrates processing of a relinkreferences in constant pool component in some embodiments.

FIG. 17 is a flow diagram that illustrates processing of an ensuredeterministic floating-point operation component in some embodiments.

DETAILED DESCRIPTION

A method and system are provided to support a decentralized distributedledger in which transactions are recorded by parties to the transactionswithout the use of a blockchain. In some embodiments, a distributedledger system provides a protocol framework that supports thedevelopment of protocol flows. A protocol flow is computer code thatcontrols the performance of a transaction by the party or parties to thetransaction. Protocol flows can be developed for different types oftransactions, such as a transaction to sell an asset from a sellingparty to a buying party, a transaction to support an interest rate swap,a transaction involving more than two parties, and so on. An examplewill help illustrate a protocol flow. In this example, a “transfer”transaction specifies to transfer a certain amount of money from an“originator” party to an “responder” party. To support such a transfertransaction, a transfer protocol flow would be developed that includescomputer code for the party in the role of the originator (“originatorcode”) and computer code for the party in the role of responder(“responder code”). When the two parties agree to consummate thetransaction, they agree on the particulars of the transaction, such asthe amount of money to transfer, the notary who is responsible fornotarizing the transaction, and to use the transfer protocol flow.

Continuing with the example of the transfer transaction, to record thetransfer transaction, the originator party starts execution of theoriginator code of the transfer protocol flow, and the responder partystarts execution of the responder code of the transfer protocol flow.The originator party provides the particulars of the transaction to theoriginator code. The originator code then sends to the responder partyits public key and the particulars of the transaction. Upon receivingthe public key and the particulars of the transaction, the respondercode verifies the particulars of the transaction (e.g., prompting a userto confirm the price). generates a proposed transaction that outlinesthe particulars of the transaction, signs the proposed transaction withthe signature of the responder party (e.g., using a private key of theresponder party), and sends the proposed transaction to the originatorcode. The proposed transaction specifies input state, output state, andidentification of a notary. The input state may specify the funds usedto buy the asset, and the output state may specify that ownership of theasset has been transferred. The input state and the output state includecontract code that is used to verify whether the transaction is valid.Upon receiving the proposed transaction, the originator code verifiesthe proposed transaction by verifying that the proposed transaction wassigned by the responder party (e.g., using the public key of theresponder party), verifying that the particulars of the proposedtransaction match those sent to the responder party, and executing thecontract code of the input state and output state of the proposedtransaction to determine whether the proposed transaction is validaccording to the contract code. When the proposed transaction is valid,the originator code accepts the proposed transaction by signing theproposed transaction with the signature of the originator party togenerate an accepted transaction. The originator code then sends theaccepted transaction to notary code of the notary specified in theproposed transaction. The notary code may be considered computer code ofthe transfer protocol code for the role of notary. Execution of thenotary code may have started when the parties decided to consummate thetransaction.

Continuing with the example, when the notary code receives the acceptedtransaction, the notary verifies that the accepted transaction has beensigned by the originator party and the responder party. The notary thendetermines whether the input state to the accepted transaction has beenalready consumed (e.g., spent by another transaction). The notary maymaintain a consumed state storage to track the output states that havebeen consumed by transactions. If the input state has not been consumed,then the notary code marks the output state of the transaction that isthe input state for the accepted transaction as now consumed andnotarizes the accepted transaction by signing the accepted transactionwith the signature of the notary to generate a notarized transaction.The notary code then sends the notarized transaction to the originatorcode.

Continuing with the example, upon receiving the notarized transaction,the originator code verifies that the notarized transaction has beensigned by the notary, records the notarized transaction in its ledger,and sends the notarized transaction to the responder code. Uponreceiving the notarized transaction, the responder code verifies thatthe notarized transaction has been signed by the notary and theoriginating party and records the notarized transaction in its ledger.In this way, both the originator party and the responder party maintaina copy of the notarized transaction in their ledgers as evidence of thenotarized transaction. The output state of the notarized transaction canbe used as an input state to a subsequent transaction, and the notarizedtransaction can be provided as evidence that the output state that isbeing used as an input state in a subsequent transaction is valid outputof the notarized transaction. For example, when verifying that the inputstate of a proposed transaction was a valid output of the priortransaction, the party that sent the proposed transaction may berequested to provide evidence of each prior transaction whose outputstate is being used as an input state to the proposed transaction.Although the proposed transaction of this example is described as havingone input state and one output state, a transaction can have zero ormore input states and zero or more output states, as long as thetransaction has at least one input state or one output state.

The distributed ledger system thus allows transactions to be proposed,accepted, and notarized by a notary and stored without the use of ablockchain ledger. In this way, the distributed ledger system can avoidthe expense of the computational and storage resources needed toredundantly verify a transaction and store evidence on the many nodes ofa blockchain distributed ledger.

In some embodiments, the computer code of a protocol flow can be ofarbitrary complexity. For example, a protocol flow can be developed tosupport transactions between any number of parties. In such a case, eachparty to the transaction would execute computer code for its role in theprotocol flow (e.g., insurer, reinsurer) that verifies, signs, andrecords the transaction as it is passed between parties and to and fromthe notary.

In some embodiments, the distributed ledger system provides a protocolframework that supports the development and execution of protocol flows.The protocol framework may provide a checkpoint service, a messagingservice, a mapping service, a deterministic virtual machine service, astatus service, and so on that are used by the protocol flows. Inaddition, a protocol flow may invoke other protocol flows, referred toas sub-protocol flows, so that many protocol flows can share the samesub-protocol flow that represents activities commonly performed byprotocol flows. For example, a sub-protocol flow may be developed tosupport the processing associated with a party requesting that anaccepted transaction be notarized.

In some embodiments, the protocol framework provides a messaging servicethat securely and reliably sends messages between nodes executing aprotocol flow. When a protocol flow at a node is to communicate withanother node, the messaging service may establish a session with theother node so that messages can be transmitted securely (e.g., viasymmetric encryption). A session may have a universally uniqueidentifier (“UUID”). The messaging service persists sessions across noderestarts and network outages. A session is used to group the messages ofa protocol flow. The messaging service also ensures delivery of amessage and may require a receiving node to confirm receipt of a message(e.g., the confirmation may include a hash of the received message). Themessaging service may provide an application programming interface thatincludes a send message and a receive message function.

In some embodiments, the checkpoint service generates checkpoints duringexecution of the protocol flow to support the restarting of the protocolflow from the last checkpoint in case of failure. The checkpoint servicemay generate a checkpoint whenever a protocol flow interacts with theprotocol framework. For example, when a protocol flow requests theprotocol framework to send a message (e.g., to a notary to request thatan accepted transaction be notarized), the protocol framework generatesa checkpoint. A checkpoint includes the state of the protocol flow atthe time of the checkpoint. For example, the state may include theprogram counter, register values, the content of the stack, and thecontent of the heap of the computer code of the protocol flow. Thecheckpoint service may employ a garbage collection technique to collectthe content of the heap that is currently accessible to the program. Thecheckpoint service then stores the checkpoint persistently. If executionof the protocol flow terminates, such as by a power failure at the nodeexecuting the protocol flow or by restarting the node for maintenancereasons, the latest checkpoint for each protocol flow can be retrievedand restored to resume execution of the protocol flow. The checkpointservice may generate the checkpoints in a manner that is transparent tothe protocol flows so that a developer of a protocol flow need not addcheckpoint code to a protocol flow.

In some embodiments, the checkpoint service may rewrite a protocol flowprior to execution so that it is resumable, rather than identifying andsaving the entire state of the protocol flow as described above. Torewrite a protocol flow, the checkpoint service may employ a Quasar-liketool (see Quasar library by ParallelUniverse) to rewrite the protocolflow. The tool rewrites the classes of computer code to implement aresumable state machine. The tool operates on the bytecodes of thecomputer code. The result of this rewriting, however, can be illustratedusing the following source computer code:

fun doFlow( ) {  Send W to A  Receive X from A  Send Y to B  Receive Zfrom B }The result of the rewriting is as follows:

fun doFlow(resumeFrom: Integer) throws SuspendExecution { switch(resumeFrom) {   case 0:    Send W to A    increment resumeFrom  case 1:    Receive X from A, throws SuspendExecution exception if no    message ready.    increment resumeFrom   case 2:    Send Y to B   increment resumeFrom   case 3:    Receive Z from B, throwsSuspendExecution exception if no     message ready.    incrementresumeFrom  } }When the rewritten protocol flow is started, the protocol frameworkcalls “doFlow(0)” to start from the beginning. During each call to thesend or receive (message) function of the messaging service, thecheckpoint service stores the current value of “resumeFrom,” along withother code state such as values of variables. When the protocol flowneeds to be restarted, then the protocol framework calls“doFlow(resumeFrom)” to continue from the point of the last checkpoint.The checkpoint service rewrites the “receive” calls so that they“suspend” if there is no message waiting to be received by throwing anexception and thus terminating the “doFlow” function. When a message isreceived for the protocol flow, the checkpoint service restarts the“doFlow” function passing resumeFrom so that the protocol flow continuesat the receive call without having to re-execute the code that wasalready executed.

In some embodiments, the protocol framework provides a mapping servicethat maps identities of entities to their corresponding address (e.g.,Internet Protocol (“IP”) address). The entities may include parties to atransaction, notaries, oracles, and so on. The identity and address ofeach entity is registered with the mapping service. When a message is tobe sent to an entity, the message is provided to the messaging servicealong with the identity of the entity to which the message is to besent. The messaging service uses the mapping service to identify fromthe identity the address of the entity to which the message is to besent.

In some embodiments, the protocol framework provides a status servicethrough which a protocol flow can report its current status. The statusservice may provide a status function that can be called by a protocolflow to report its current status. For example, a protocol flow mayreport that is awaiting a response from a notary. The status service mayalso provide an interface (e.g., user interface) through which anadministrator, another user, or a program can track and/or determine thecurrent status of a protocol flow. For example, if a protocol flow hasbeen waiting for a response from a notary for an unusually long time, anadministrator may be notified to investigate because the node on whichthe notary executes may have failed.

In some embodiments, the protocol framework ensures that contract codeexecutes in a deterministic manner such that the contract code producesthe same output state for the same input state so that parties can agreeon whether a transaction is valid. Because transaction types are definedusing bytecodes (e.g., of a Java virtual machine “JVM”), the executionof the bytecodes should be fully deterministic. Standard virtualmachines, such as a JVM, may not be fully deterministic. To ensure thatthe execution of the bytecodes is deterministic, the protocol frameworkincludes a deterministic virtual machine service that modifies contractcode to ensure that it executes deterministically as described below indetail.

In some embodiments, a transaction includes input references, outputstates, commands, attachments, a timestamp, signatures (e.g., of partiesand notary), and a summary. An input reference identifies an outputstate of a prior transaction that is an input state to this transaction.An input reference may include a hash of the prior transaction and anidentifier of the output state of that prior transaction. An outputstate identifies the output of the transaction, such as the new owner(e.g., of funds or another financial instrument), dollar amount, type oftransaction, a reference to contract code, a reference to text of thecontract, and so on. A command is an input to the contract code. Forexample, a command may specify a further refinement of verification ofthe transaction. A command may also have one or more associatedidentifications (e.g., public keys) of parties whose signatures areneeded as approval for use of the command as an input parameter. Anattachment is a file (e.g., a Zip file) that can contain arbitrarycontent that is accessible to the contract code. A timestamp is a timerange in which the transaction is asserted to have occurred. A timestampmay be needed, for example, because of regulatory requirements or asproof of time of payment. The signature of a notary on a transactionindicates that the notary has confirmed that the timestamp is accurate.A summary is a text description that may be displayed to a userapproving a transaction as evidence of the content of the transaction.

In some embodiments, a notary service of the distributed ledger systemprovides transaction ordering and timestamping services in addition totransaction verification and notarizing services. The notary service maybe provided by a notary service that decides whether to notarize atransaction or a notary service that interfaces with other mistrustingnotary services who use a consensus algorithm such as a Byzantine faulttolerance algorithm or a Raft consensus algorithm to decide whether tonotarize a transaction. The notary services receive acceptedtransactions, verify whether the input states of the transactions havebeen consumed, and if they have not, sign the accepted transaction. If anetwork has multiple notaries, then notary services can seamlessly bephased in or out, a notary service can be jurisdiction-specific tocomply with jurisdictional regulations, notary services can competebased on availability and performance, and so on.

In some embodiments, the protocol framework supports the scheduling ofevents. For example, a protocol flow may need to manage expiration of anoption contract, to manage a contract default, to re-fix an interestrate swap, and so on. To support the scheduling of events, the contractcode of a state (i.e., input or output) may have a scheduling functionfor providing the next time a protocol flow is to be executed to processthe state. When a notarized transaction is recorded, the protocolframework invokes the scheduling function of the state (e.g., outputstate) of the notarized transaction. The scheduling function returns atime in which a protocol flow is to be next executed. The protocolframework records the time and then starts the protocol flow at therecorded time.

FIG. 1 is a diagram that illustrates an example transaction in someembodiments. A transaction A 103 is proposed to make both a contractpayment and an associated insurance payment for the contract.Transaction A specifies the input states of input state A 101 and inputstate B 102. The input state A specifies that the owner has $2000, andthe input state B specifies that the owner has $5000. Transaction Aspecifies the output states of output state C 104 and output state D105. The output state C specifies to make a contract payment of $6500,and the output state D specifies to make an insurance payment of $500.State content 106 illustrates example content of a state. To proposetransaction A, the proposing (or proposer) party executes a protocolflow for the transaction. The protocol flow generates transaction A,which specifies the input states, the output states, and an identifierof a notary. The output states may identify the accepting (or acceptor)parties for accepting the contract payment and the insurance payment.The protocol flow then signs transaction A with the private key of theproposing party and sends transaction A as a proposed transaction to theaccepting parties in sequence. Each accepting party verifies thattransaction A has been signed by the proposing party and invokes thecontract code of the input states and at least its output state toensure that the proposed transaction complies with the terms of thecontract. Each accepting party then accepts transaction A by signingtransaction A with its private key and sends the accepted transaction Ato the proposing party. When accepted by all accepting parties, theproposing party submits accepted transaction A to a notary. The notaryverifies the signatures of accepted transaction A, timestamps acceptedtransaction A, ensures that the input states have not yet been consumed,and notarizes the accepted transaction A by signing with the notary'sprivate key to generate a notarized transaction A. The notary then sendsthe notarized transaction A to the proposing party, who records thenotarized transaction A and forwards the notarized transaction A to theaccepting parties, who each record the notarized transaction A.

FIG. 2 is a block diagram illustrating components of the distributedledger system in some embodiments. A distributed ledger system may beimplemented on nodes of a network 200. Each entity (e.g., party to acontract, notary, mapping service) may have one or more nodes registeredwith the network. FIG. 2 illustrates that the network includes aproposer node 210, an acceptor node 220, a notary node 230, and amapping service node 240 that communicate a via communications channel250. The proposer node includes a protocol flow 211 and protocolframework components 212. The protocol flow 211 may represent the flowfor a proposer role of a two-party contract protocol flow. The protocolframework components include a create (or instantiate) flow component213, a verify transaction component 214, a resolve transaction component215, an execute verify function component 216, a checkpoint store 217,and a transaction store 218. The create flow component instantiates aprotocol flow for execution. The verify transaction component verifiessignatures of a proposed transaction, invokes the resolve transactioncomponent to ensure that the input states of the proposed transactionare valid, and invokes the execute verify function to execute thecontract code of the input and output states of the proposed transactionto ensure that the proposed transaction complies with the terms of thecontract. The checkpoint store component stores checkpoints generated bythe checkpoint service (not illustrated) for restarting a protocol flow.The transaction store, which may be referred to as a vault, storesnotarized transactions and may store private keys. The protocolframework components may also include a component for providingnotarized transactions to the accepting party for verification of inputstates, a component for sending and receiving messages, and so on, whichare not illustrated in FIG. 2 . The acceptor node includes a protocolflow 221, which may represent the flow of an acceptor role of thetwo-party contract protocol flow, and components 223-226 and stores227-228, which correspond to components 213-216 and stores 217-218 ofthe originator node. The notary node includes a notary component 231 anda consumed state store 232. The notary component controls verifying thesignatures of an accepted transaction, ensuring that the input statesare not yet consumed, and notarizing the accepted transaction. Thenotary component stores an indication of each consumed state in theconsumed state store to prevent double-spending of the consumed outputstate. The input state may be identified by a hash of the transactionthat generated the output state that is being used as the input statealong with an identifier of which output state of the transaction isbeing used as the input state. The mapping service node includes a getIP address component 241 and an entity/IP address store 242. The get IPaddress component receives a request for an IP address that correspondsto a given identity of an entity and returns the IP address of a nodeassigned to the entity. The entity/IP address stores a mapping of entityidentifiers to IP addresses of their nodes.

The computing systems (e.g., nodes) on which the distributed ledgersystem may be implemented may include a central processing unit, inputdevices, output devices (e.g., display devices and speakers), storagedevices (e.g., memory and disk drives), network interfaces, graphicsprocessing units, cellular radio link interfaces, global positioningsystem devices, and so on. The input devices may include keyboards,pointing devices, touch screens, gesture recognition devices (e.g., forair gestures), head and eye tracking devices, microphones for voicerecognition, and so on. The computing systems may include desktopcomputers, laptops, tablets, e-readers, personal digital assistants,smartphones, gaming devices, servers, and so on. The computing systemsmay access computer-readable media that include computer-readablestorage media and data transmission media. The computer-readable storagemedia are tangible storage means that do not include a transitory,propagating signal. Examples of computer-readable storage media includememory such as primary memory, cache memory, and secondary memory (e.g.,DVD) and other storage. The computer-readable storage media may haverecorded on it or may be encoded with computer-executable instructionsor logic that implements the distributed ledger system. The datatransmission media is used for transmitting data via transitory,propagating signals or carrier waves (e.g., electromagnetism) via awired or wireless connection. The computing systems may include a securecryptoprocessor as part of a central processing unit for generating andsecurely storing keys and for encrypting and decrypting data using thekeys.

The distributed ledger may be described in the general context ofcomputer-executable instructions, such as program modules andcomponents, executed by one or more computers, processors, or otherdevices. Generally, program modules or components include routines,programs, objects, data structures, and so on that perform particulartasks or implement particular data types. Typically, the functionalityof the program modules may be combined or distributed as desired invarious examples. Aspects of the distributed ledger system may beimplemented in hardware using, for example, an application-specificintegrated circuit (ASIC) or field programmable gate array (“FPGA”).

FIG. 3 is a flow diagram illustrating processing of an example flow forthe role of an acceptor for a protocol flow in some embodiments. Anacceptor component 300 is executed when an accepting party wants toexecute a transaction with a proposing party. The accepting party andthe proposing party may agree outside of the distributed ledger systemto the terms of the transaction (also referred to as deal particulars).In block 301, the component inputs the deal particulars, such as adollar amount that is to be transferred between the parties, a notary touse, and so on. In block 302, the component sends to the proposing partythe public key (e.g., via a public key certificate) of the acceptingparty and the deal particulars. In block 303, the component receivesfrom the proposing party a proposed transaction that is signed by theproposing party. In block 304, the component invokes a verifytransaction component to verify the proposed transaction, includingverifying the signature of the proposing party. In decision block 305,if the proposed transaction has been verified, then the componentcontinues at block 306, else the component performs some errorprocessing such as alerting an administrator. In block 306, thecomponent signs the proposed transaction with the private key of theaccepting party to generate an accepted transaction. In block 307, thecomponent sends the accepted transaction to the notary specified in theaccepted transaction. In block 308, the component receives from thenotary the notarized transaction. In block 309, the component sends tothe proposing party the notarized transaction. In block 310, thecomponent records the notarized transaction in the vault of theaccepting party. The component then completes.

FIG. 4 is a flow diagram that illustrates processing of an example flowfor the role of the proposer of the protocol flow of FIG. 3 in someembodiments. A proposer component 400 is executed when a proposing partywants to execute a transaction with an accepting party. The componentinitially inputs the deal particulars, such as a dollar amount that isto be transferred between the parties, a notary to use, and so on. Inblock 401, the component receives from the accepting party the publickey of the accepting party and an indication of the deal particulars.Alternatively, the component may retrieve the public key from acertificate authority, from a service that stores public keys, or fromsome other service. In block 402, the component checks the received dealparticulars to ensure that they conform with the input deal particulars.In decision block 403, if the deal particulars conform, then thecomponent continues at block 404, else the component performs errorprocessing such as alerting an administrator. In block 404, thecomponent generates a proposed transaction that specifies the inputstates, the output states, and the identification of the notary. Inblock 405, the component signs the proposed transaction with the privatekey of the proposing party. In block 406, the component sends to theaccepting party the signed proposed transaction. In block 407, thecomponent receives from the accepting party a notarized transaction. Inblock 408, the component verifies the notarized transaction by using thepublic key of the notary and the public key of the accepting party toensure that the notarized transaction has been signed by the notary andthe accepting party. In decision block 409, if the notarized transactionis verified, then the component continues at block 410, else thecomponent performs some error processing such as alerting anadministrator. In block 410, the component records the notarizedtransaction and then completes. Although not illustrated in FIGS. 3 and4 , the components may periodically notify the protocol framework of thestatus of the protocol flow so that the protocol framework may publishthe status so that the status is available to administrators, errorprocessing components, and so on. For example, the proposer componentmay update the status when it initially starts up, receives the dealparticulars, verifies the deal particulars, sends the proposedtransaction, receives the notarized transaction, and records thenotarized transaction. In addition, the protocol framework, may generatecheckpoints whenever a component passes control to the protocolframework, such as when sending or receiving a message, updating thestatus, and so on.

FIG. 5 is a flow diagram that illustrates processing of a notary servicein some embodiments. A notary component 500 may be an implementation ofa role of a notary for a protocol flow. In block 501, the componentreceives from the accepting party an accepted transaction that is to benotarized. In block 502, the component verifies the signatures of theaccepted transaction using the public keys of the proposing party andthe accepting party. In decision block 503, if the signatures areverified, then the component continues at block 504, else the componentcontinues at block 507. In blocks 504-506, the component loopsdetermining whether the input states of the accepted transaction havebeen consumed. In block 504, the component selects the next input stateof the transaction. In decision block 505, if all the input states havealready been selected, then none of the input states have been consumedand the component continues at block 508, else the component continuesat block 506. In block 506, if the selected input state has beenconsumed as indicated by the consumed state store, the componentcontinues at block 507, else the component loops to block 504 to selectthe next input state of the accepted transaction. In block 507, thecomponent sends to the accepting party a failure notification indicatingthat the transaction cannot be notarized because at least one inputstate has been consumed and then completes. In some embodiments, thecomponent may also send a notification directly to the proposing party.For example, the proposing party may have registered with the notaryservice to receive notifications and notarized transactions or thenotary flow may automatically send the notifications or notarizedtransactions to all parties of the transaction. In block 508, thecomponent records the transaction input states as being consumed byupdating the consumed transaction store. In block 509, the componentnotarizes the accepted transaction to generate a notarized transactionby signing it with the private key of the notary. In block 510, thecomponent sends to the accepting party (and optionally to the proposingparty) the notarized transaction and then completes.

FIG. 6 is a flow diagram that illustrates processing of a create flowcomponent of the protocol framework in some embodiments. A create flowcomponent 600 may be passed an indication of a protocol flow, a role ofthe protocol flow, and entities involved in the transaction. In block601, the component may record a checkpoint for the protocol flow. Inblock 602, the component may retrieve the code for the role of theprotocol flow. The component may also rewrite the code to enable it tobe resumable if the code has not yet been rewritten. In block 603, thecomponent may launch execution of the code. In block 604, the componentmay use the mapping service to identify the IP addresses of the entitiesinvolved in the protocol flow. In block 605, the component may establishcommunication sessions with nodes of the entities. Alternatively, theprotocol framework may establish the sessions when a protocol flow firstsends a message to an entity. The component then completes.

FIG. 7 is a flow diagram that illustrates processing of a verifytransaction component of the protocol framework in some embodiments. Averify transaction component 700 is invoked by an accepting party toverify the signature of the proposing party and verify that the inputstates and output states are valid. In block 701, the component uses thepublic key of the proposing party to check that the proposed transactionhas been signed by the proposing party. In decision block 702, if thesignature has been verified, then the component continues at block 703,else the component completes and indicates that the proposed transactionis not verified. In block 703, the component invokes a resolvetransaction component passing an indication of the proposed transactionto verify whether the contract code of the input states and the outputstates indicate that the transaction is valid and whether the inputstates are also from valid transactions. In decision block 704, if theresolve transaction component indicates that the transaction isverified, then the component completes and indicates that the proposedtransaction is verified, else the component completes and indicates thatthe proposed transaction is not verified.

FIG. 8 is a flow diagram that illustrates processing of a resolvetransaction component of the protocol framework in some embodiments. Aresolve transaction component 800 verifies that the input states to theproposed transaction are output states of valid transactions and thatthe contract code of the input states and the output states of theproposed transaction indicate that the proposed transaction is valid. Inblocks 801-804, the component loops checking the validity of each inputstate. In block 801, the component selects the next input state of theproposed transaction. In decision block 802, if all the input stateshave already been selected, then all the input states are valid and thecomponent continues at block 805, else the component continues at block803. In block 803, the component recursively invokes the checktransaction inputs component passing an indication of the transaction ofthe selected input state. In decision block 804, if the input state hasbeen verified as being valid, then the component loops to block 801 toselect the next input state, else the component completes and indicatesthat the proposed transaction is not verified. In block 805, thecomponent invokes an execute verify function of the protocol frameworkto invoke the contract code of the proposed transaction to determinewhether the proposed transaction complies with the terms of thecontract. In decision block 806, if the proposed transaction isverified, then the component completes and indicates that the proposedtransaction is verified, else the component completes and indicates thatthe proposed transaction is not verified.

FIG. 9 is a flow diagram that illustrates processing of an executeverify function component of the protocol framework in some embodiments.An execute verify function component 900 is invoked to execute contractcode associated with the input states and output states of a transactionto determine whether the transaction is valid. The component isresponsible for rewriting contract code so that it can be executeddeterministically, which is described below in more detail. In block901, the component selects an input state or output state that has notyet been selected. In decision block 902, if all the input states andoutput states have already been selected, then the component completesand indicates that the proposed transaction is verified, else thecomponent continues at block 903. In block 903, the component extractsan identifier of the contract code from the selected state of theproposed transaction. In block 904, the component accesses storage toretrieve the contract code if it has already been rewritten. In decisionblock 905, if the rewritten contract code is found, then the componentcontinues at block 909, else the component continues at block 906. Inblock 906, the component invokes a rewrite contract code component torewrite the contract code so that it executes deterministically. Indecision block 907, if the rewriting of the contract code wassuccessful, then the component continues at block 908, else thecomponent completes and indicates that the transaction is not verified.In block 908, the component stores the rewritten contract code in thestorage for later retrieval to avoid having to rewrite the contract codeagain. In block 909, the component invokes the verify function of thecontract code. The contract code is executed by a virtual machine suchas JVM that may be adapted to support deterministic execution of thecontract code. In decision block 910, if the verify function verifiesthat the transaction is valid, then the component loops to block 901 toselect another input state or output state, else the component completesand indicates that the proposed transaction is not verified.

FIG. 10 is a flow diagram illustrating processing of a send messagecomponent of the protocol framework in some embodiments. A send messagecomponent 1000 is invoked by a source flow to send a message from thesource flow to a target flow executing at nodes in the network. In block1001, the component suspends execution of the source flow and records acheckpoint for the source flow. In block 1002, the component sends tothe IP address of the target flow the message. In block 1003, thecomponent receives a receipt from the target flow (or the protocolframework supporting the target flow) as confirmation that the messagewas received. In block 1004, the component records a checkpointindicating that the receipt has been received. In block 1005, thecomponent resumes execution of the source flow and then completes.

FIG. 11 is a flow diagram that illustrates processing of a receivemessage component of the protocol framework in some embodiments. Areceive message component 1100 is invoked by a target flow to receive amessage sent from a source flow. In block 1101, the component suspendsexecution of the target flow and records a checkpoint for the targetflow. In block 1002, the component receives a message from the sourceflow. In block 1103, the component records a message received checkpointfor the target flow. In block 1104, the component resumes execution ofthe target flow passing the message to the target flow. In block 1105,the component sends to the source flow a receipt confirming that themessage was received and then completes.

Description of Deterministic JVM

The distributed ledger system helps ensure that all nodes that process atransaction agree on whether it is valid or not. Because transactiontypes are defined using bytecodes (e.g., of a JVM), the execution of thebytecodes should be fully deterministic. Standard virtual machines, suchas a JVM, may not be fully deterministic. To ensure that the executionof the bytecodes is deterministic, the protocol framework includes arewrite contract code component that modifies contract code to ensurethat it executes deterministically. Table 1 illustrates example possiblesources of non-determinism.

TABLE 1   Sources of external input (e.g., the file system, network,system properties, and clocks) Random number generators Differentdecisions about when to terminate long running programs Object.hashCode() Differences in hardware floating point arithmetic operationsMulti-threading Differences in API implementations between nodes Garbagecollector callbacks

To ensure that contract code is fully pure (i.e., deterministic and withno side effects), the distributed ledger system employs a new type ofJVM sandbox. The distributed ledger system may rewrite the bytecodebased on a static analysis of the bytecode and modify the JVM to controlthe behavior of hash code generation and invocation if non-deterministicfunctions. The rewrite contract code component may rewrite the bytecodeof a contract code before it is first executed and store the rewrittenbytecode for future executions. Table 2 illustrates example tasksperformed during the rewriting of the bytecode.

TABLE 2   Inserts calls to an accounting object before expensivebytecodes Prevents exception handlers from catching certain exceptions(e.g., Throwable, Error, or ThreadDeath) Adjusts constant poolreferences to relink the code against a “shadow” runtime library (e.g.,JDK) Directs the use of hardware independent floating point operationsForbids dynamic invocation (e.g., invokedynamic bytecodes), nativemethods, and finalizers

The rewrite contract code component instruments the contract code byinserting calls to an accounting object to deterministically terminatecode that has run for an unacceptable amount of time or used anunacceptable amount of memory. The accounting object checks atermination criterion to determine whether to terminate the execution ofthe contract code. For example, the accounting object may determine anaccumulated cost of execution (e.g., based on number and types ofbytecodes executed and memory used). The termination criterion mayspecify that execution of the contract code should terminate when anaccumulated cost threshold is reached. Because execution of the contractcode is deterministic, given the same input, every execution of thecontract code will terminate at the same point that is when thetermination criterion is satisfied or when execution terminatesnormally. Particularly, expensive bytecodes may include methodinvocation, allocations, backwards jumps, throwing of exceptions, and soon. The rewrite contract code also instruments code that can betransitively reached from the contract code. For example, the shadowruntime library may be instrumented prior to execution of any contractcode.

The rewrite contract code component may assess the cost of execution bycounting bytecodes that are known to be expensive to execute. Since thesize of a method is limited and jumps count towards the cost, theassessment of cost will eventually terminate. However, it is stillpossible to construct bytecode sequences that take excessive amounts oftime to execute even though they do not use expensive operations. Forexample, contract code with very nested method calls in which themost-nested methods perform inexpensive bytecodes may accumulate to beexpensive. The instrumentation of the contract code ensures thatinfinite loops are terminated and that if the cost of verifying atransaction becomes unexpectedly large (e.g., contains algorithms withcomplexity exponential in transaction size), all nodes agree preciselyon when to terminate. The instrumentation may not provide protectionagainst denial of service attacks. If a node receives transactions thatappear designed to simply waste CPU time of the node, then the node canblock the sending node.

In some embodiments, because instrumentation may be a high overhead, therewrite contract code component may statically calculate bytecode costsas much as possible ahead of time and instrument only the entry point of“accounting blocks” such as runs of basic blocks that end with either amethod return or a backwards jump. Because only an abstract cost (e.g.,a general sense of the magnitude of the cost) matters and because thelimits are expected to be set relatively high, the rewrite contract codecomponent not need instrument every basic block. For example, therewrite contract code component may use the maximum of the cost of the“then” block and the cost of the “else” block of an if-then-elsestatement when neither block contains a backwards jump. In such a case,the rewrite contract code need only instrument before the if-then-elsestatement and need not instrument the blocks.

The shadow runtime library duplicates a subset of the standard runtimelibrary, but inside a dedicated sandbox package. The shadow runtimelibrary may omit functionality that contract code is not permitted toaccess such as file I/O or external entropy (e.g., such as a randomnumber generator).

In some embodiments, the rewrite contract code component may direct theuse of hardware independent floating-point operations by setting thestrictfp flag on every method of the contract code and of code that istransitively called.

In some embodiments, the rewrite contract code component may prohibitfinalizers in contract code because finalizers have been known to beimplemented non-deterministically. The rewrite contract code componentmay prohibit calls via a Java Native Interface as the called applicationmay behave non-deterministically. The rewrite contract code componentmay prohibit the invokeddynamic bytecode because libraries supportingthe invokeddynamic bytecode has been known to have security problems.

In some embodiments, the JVM sandbox may impose a quota on bytesallocated rather than bytes retained. If contract code allocates andquickly deallocates large numbers of bytes (resulting in a small heapsize), a quota based on bytes allocated may unnecessarily penalize suchcontract code. Alternatively, the JVM sandbox may employ a garbagecollector to identify the heap size and impose a quota based on heapsize.

The Object.hashcode( ) is typically implemented either by returning apointer address or by assigning the object a random number and thus canresult in different iteration orders over hash maps and hash sets. Toprevent this non-deterministic behavior, the distributed ledger systemmay modify calls to the Object.hashCode( ) function with new Java NativeInterface (“JNI”) calls that reseeds the JVM's thread local randomnumber generator before execution begins. The seed may be derived fromthe hash of the transaction being verified to ensure that allverifications of the transaction use the same seed and thus the samehash code.

FIG. 12 is a flow diagram that illustrates processing of a rewritecontract code component in some embodiments. A rewrite contract codecomponent 1200 is invoked when contract code is first executed torewrite the contract code so that it operates deterministically. Inblock 1201, the component invokes a check for forbidden constructscomponent to determine whether the contract code includes any forbiddenconstructs. In decision block 1202, if a forbidden construct is found,then the component completes indicating a failure to rewrite thecontract code, else the component continues at block 1203. In block1203, the component invokes an instrument expensive bytecodes componentto instrument bytecodes that are expensive to execute. In block 1204,the component invokes a disable forbidden exception catching componentto disable the catching of certain exceptions. In block 1205, thecomponent invokes a relink references in constant pool component torelink references from the runtime library to the shadow runtimelibrary. In block 1206, the component invokes an ensure deterministicfloating-point operation component to direct that floating-pointoperations are hardware independent. In block 1207, the component storesthe rewritten contract code for subsequent execution and then completesindicating success.

FIG. 13 is a flow diagram that illustrates processing of a check forforbidden constructs component in some embodiments. A check forforbidden constructs component 1300 is invoked to ensure that contractcode is not executed that includes forbidden constructs. In block 1301,the component selects the next bytecode of the contract code startingwith the first. In decision block 1302, if all the bytecodes havealready been selected, then the component completes returning anindication that forbidden constructs were not found, else the componentcontinues at block 1303. In decision blocks 1303-1305, the componentdetermines whether the bytecode is a forbidden construct. If so, thecomponent completes indicating that a forbidden construct was found. Ifnot, the component loops to block 1301 to select the next bytecode ofthe contract code.

FIG. 14 is a flow diagram that illustrates processing of an instrumentexpensive bytecodes component in some embodiments. An instrumentexpensive bytecodes component 1400 is invoked to determine whetherbytecodes are expensive to instrument and if so, adds an accountingobject before each such bytecode. The accounting object is responsiblefor terminating execution of the contract code if execution is takingtoo long or consuming too much memory. In a block 1401, the componentselects the next bytecode of the contract code starting with the first.In decision block 1402, if all bytecodes have already been selected,then the component completes, else the component continues at block1403. In decision block 1403, if the selected bytecode is expensive,then the component continues at block 1404, else the component loops toblock 1402 to select the next bytecode. In block 1404, the componentinserts an accounting object before the selected bytecode and then loopsto block 1401 to select the next bytecode.

FIG. 15 is a flow diagram that illustrates processing of a disableforbidden exception catching component in some embodiments. A disableforbidden exception catching component 1500 is invoked to ensure thatthe contract code does not catch certain exceptions. For example, anaccounting object may want to terminate the thread on which the contractcode is executing as a result of the contract code using an excessiveamount of computational resources. In such a case, the accounting objectmay direct that an exception be thrown, which should not be handled bythe contract code. In block 1501, the component selects the nextbytecode of the contract code starting with the first. In decision block1502, if all the bytecodes have already been selected, then thecomponent returns, else the component continues at block 1503. Indecision blocks 1503-1505, the component determines whether the bytecoderepresents the catching of a forbidden exception. If so, in block 1506,the component disables the catching of the exception and then loops toblock 1501 to select the next bytecode. If not, the component loops toblock 1501 to select the next bytecode.

FIG. 16 is a flow diagram that illustrates processing of a relinkreferences in constant pool component in some embodiments. A relinkreferences constant pool component 1600 is invoked to relink thereferences to the shadow runtime library. In block 1601, the componentselects the next reference in the constant pool. In decision block 1601,if all the references have already been selected, then the componentcompletes, else the component continues at block 1603. In block 1603,the component relinks the reference to the corresponding shadow code inthe shadow runtime library and then loops to block 1601 to select thenext reference.

FIG. 17 is a flow diagram that illustrates processing of an ensuredeterministic floating-point operation component in some embodiments. Anensure deterministic floating-point operations 1700 is invoked to directeach method to use hardware independent floating-point operations. Inblock 1701, the component selects the next method of the contract code.In decision block 1702, if all the methods have already been selected,then the component completes, else the component continues at block1703. In block 1703, the component directs the method to performhardware independent floating-point operations such as by setting thestrictfp flag of a Java method and then loops to block 1701 to selectthe next method of the contract code.

Description of Secure Signing Devices

In some embodiments, the distributed ledger system may employ securesigning devices that provide secure client-side hardware to hold privatekeys and to perform signing operations with the private keys. Thedistributed ledger system may employ advance devices like the TREZOR bySatoshi Labs or the Ledger Blue. These devices are improvements overChip Authentication Program (“CAP”) readers in that they have betterdisplays and transmit responses electronically (e.g., USB, NFC, orBluetooth), rather than by a person manually copying and typing in theresponse. These devices differ from CAP readers in another key respect:instead of signing arbitrary, small challenge numbers, they understandthe native transaction format of the network for which they arespecialized and parse a transaction to determine what message to displayto the user, who then confirms that they wish to perform the displayedaction by simply pressing a button. The device then signs thetransaction before sending the signed transaction to the computer (e.g.,personal computer) that sent the transaction to the device.

The use of such advanced devices enables a device to control the assetsthat are recorded at a server. The private key can also be exported fromthe device by writing it down in the form of “wallet words:” 12 randomwords derived from the contents of the elliptical curve private key.Because elliptic curve private keys are small (256 bits), this is not astedious as it would be with the much larger RSA keys that are typicallyused by the financial industry. Because the signing keys are personal,an employee of an organization with a signing key is responsible forsigning transactions, rather than having a node of the organization beresponsible for signing transactions. Thus, if an organization node ishacked by a malicious intruder or bad insider, the hacker cannot stealassets, modify agreements, or do anything else that requires humanapproval, because the hacker does not have access to the signing keys.In addition, it is indisputable who signed a particular transaction. Theindisputability is especially true if the device provides for biometricauthentication (e.g., fingerprint or retinal scan) of the user.

A difficulty with such advanced devices (and CAP readers) is that theyare susceptible to confusion attacks. A confusion attack may occur whena hacker modifies a transaction, for example, to replace the accountnumber of the intended recipient with the account number of the hacker.When the user sees the account number on the device, the user may notrealize that the account number is wrong and sign the transaction. Tohelp prevent confusion attacks, the distributed ledger system allows atransaction to include a transaction summary in addition to the inputstates, the output states, the contract code, the commands, and so on.The contract code is responsible for generating a message from the textof the transaction summary. When the transaction is downloaded to thedevice for signing, the contract code is invoked to generate the messageto be displayed to the user. Because the downloaded transaction issigned (i.e., by encrypting a hash of the transaction and encrypting thehash with a private key), the authenticity of the transaction and themessage can be confirmed by the user.

In some embodiments, it may not be desirable to download an entiretransaction to a device. For example, the device may have a relativelysmall amount of storage that would place an undesirable limitation onthe maximum size of a transaction. The distributed ledger system maysupport representing the hash of a transaction as a Merkle tree with theroot node corresponding to the hash of the transaction, each non-leafnode corresponding to a hash of its children, and each leaf nodecorresponding to a hash of a part of the transaction such as atransaction summary, each input state and output state, attachments, andcommands. With a Merkle tree representation of a transaction, thedistributed ledger system need only provide the device with the nodes(and each node's sibling nodes) along the path from the root node tonode of the hash of the transaction summary. The device can thengenerate a hash of the transaction summary and confirm that the hash wasused to generate a hash of the root node. A signed hash of thetransaction may also be provided to the device so that the device canensure that the party that signed the hash attests to the authenticityof the hash. In this way, the device can be assured that the transactionsummary is from the transaction represented by the hash of the rootnode. Thus, when the user signs off on the transaction after thetransaction summary is displayed, the device can sign the hash of thetransaction (i.e., the hash of the root node) and provide the signedhash to the computer as the signature of the user.

A Merkle tree representation may be useful to provide only certain partsof a transaction to other entities. For example, an oracle may need toconfirm a term of a contract such as an interest rate. In such a case,the nodes (and their sibling nodes) of the Merkle tree from the rootnode to the leaf node with the hash of the interest rate node can beprovided to the oracle. The oracle, in a similar manner to that of asecure device, can check the hashes and sign off on the transaction. AMerkle tree representation may also allow entities to sign off onportions of a transaction rather than on an entire transaction. Forexample, an oracle may only need to sign the hash of the interest ratenode to make it clear that the oracle is attesting to only theauthenticity of the interest rate.

The following paragraphs describe various embodiments of aspects of thedistributed ledger system. An implementation of the distributed ledgersystem may employ any combination of the embodiments. The processing ofthe methods described below may be performed by a computing device witha processor that executes computer-executable instructions stored on acomputer-readable storage medium that implements the distributed ledgersystem.

In some embodiments, a distributed ledger system provides a methodperformed by a computing system for coordinating a transaction betweenparties. The method proposes a transaction between a first party and asecond party by generating a proposed transaction that specifies a statethat includes at least one of an input state and an output state (butmay include zero or more input states and outputs), and specifies anidentifier of a notary. The state has contract code for verifying thatthe proposed transaction complies with terms of a contract. The methodalso signs the proposed transaction with a signature of the first partysends the proposed transaction to the second party. The method thenreceives an accepted transaction that indicates acceptance of theproposed by the second party. The method verifies that the notarizedtransaction has been accepted by the second party and has been notarizedby ensuring the accepted transaction matches the proposed transactionand that the notarized transaction has been signed by the second partyand the notary. The method then records the notarized transaction in adecentralized storage so that the notarized transaction is accessible bythe first party. In some embodiments, the decentralized storage allowsnotarized transactions to be recorded by the parties to the notarizedtransactions as proof of the notarized transactions without the need forthird parties to record the notarized transactions. In some embodiments,a signature is a hash of a transaction that is signed using a privatekey of a signer. In some embodiments, the proposed transaction isbetween the first party, the second party, and a third party and themethod verifies that the notarized transaction has been accepted by thethird party by ensuring that the notarized transaction has been signedby the third party. In some embodiments, the method generatescheckpoints during execution of the protocol flow, each checkpointincluding state of the protocol flow at the time of the checkpoint andstores the checkpoints persistently so that if execution of the protocolflow is suspended, execution can be resumed from the latest checkpoint.In some embodiments, the generating of the checkpoints is transparent tothe protocol flow. In some embodiments, the method tracks a status ofthe protocol flow for reporting to the first party. In some embodiments,the method, prior to execution of a protocol flow, rewrites the protocolflow so that the protocol flow is resumable. In some embodiments, theproposed transaction includes multiple input states and multiple outputstates. In some embodiments, the transaction includes a command as aninput parameter to the contract code. In some embodiments, the commandhas one or more associated identification of parties and whereinverification of the proposed transaction by the contract code ensuresthat the proposed transaction has been signed by the identified parties.In some embodiments, the identification of a party is a public key. Insome embodiments, the transaction includes an attachment with contentthat is accessible by the contract code. In some embodiments, aprocessor of the computing system executes instructions of a protocolflow by executing a virtual machine the executes bytecodes of theprotocol flow. In some embodiments, the virtual machine is a Javavirtual machine. In some embodiments, the method receives a request toprovide a notarized transaction on which the proposed transactiondepends, retrieves the notarized transaction on which the proposedtransaction depends from the decentralized storage, and provides theretrieved transaction to the second party. In some embodiments, themethod requests assistance for the protocol flow when an error conditionis detected. In some embodiments, the method securely and reliably sendsmessages between a node of the first party and a node of the secondparty. In some embodiments, the method provides receipts to confirmdelivery of messages.

In some embodiments, a distributed ledger system provides a methodperformed by a computing system for coordinating a transaction betweenparties. The method receives a proposed transaction between a firstparty and a second party. The proposed transaction being proposed andsigned by the first party. The proposed transaction specifies state thatincludes at least an input state or an output state, and specifies anidentifier of a notary. The state has contract code for verifying theproposed transaction complies with terms of a contract. The methodverifies the proposed transaction has been signed by the first party.The method further verifies the proposed transaction by verifying thatthe input state is valid and executing the contract code of the state toensure that the proposed transaction complies with the terms of thecontract. The method generates an accepted transaction by signing theproposed transaction with a signature of the second party andcoordinating with the notary identified in the transaction to have theaccepted transaction notarized to generate a notarized transaction. Themethod sends the notarized transaction to the first party. The methodrecords the notarized transaction in a decentralized storage so that thenotarized transaction is accessible by the second party. In someembodiments, the decentralized storage allows notarized transactions tobe recorded by the parties to the notarized transaction as proof of thenotarized transactions without the need for third parties to record thenotarized transactions. In some embodiments, a signature is a hash of atransaction that is signed using a private key of a signer. In someembodiments, the method generates checkpoints during execution of theprotocol flow. Each checkpoint includes state of the protocol flow atthe time of the checkpoint. The method stores the checkpointspersistently so that if execution of the protocol flow is suspended,execution can be resumed from the latest checkpoint. In someembodiments, the generating of the checkpoints is transparent to theprotocol flow. In some embodiments, the method tracks a status of theprotocol flow for reporting to the second party. In some embodiments,the method prior to execution of the instructions of the protocol flow,rewrites the instructions of the protocol flow so that the protocol flowis resumable. In some embodiments, the proposed transaction includeszero or more input states and zero or more output states. In someembodiments, the transaction further includes a command as an inputparameter to the contract code. In some embodiments, the command has oneor more associated identification of parties and wherein verification ofthe proposed transaction by the contract code ensures that the proposedtransaction has been signed by the identified parties. In someembodiments, the identification of a party is a public key. In someembodiments, a processor of the computing system executes a virtualmachine that executes bytecodes of the a protocol flow. In someembodiments, the virtual machine is a Java virtual machine. In someembodiments, the method prior to execution of the contract code,rewrites contract code so that the contract code is deterministic. Insome embodiments, the state is input state that is an output state of aninput transaction, and the method executes contract code of the outputstate of the input transaction to determine whether input transactionand the input state are valid. In some embodiments, the methodtransitively verifies the validity of input states on which the proposedtransaction depends. In some embodiments, the method sends to the firstparty request to provide notarized transaction on which the proposedtransaction depends and receive from the first party the requestednotarized transaction. In some embodiments, the method requestsassistance for the protocol flow when an error condition is detected. Insome embodiments, the method securely and reliably sends messagesbetween a node of an entity and a node of the another entity. In someembodiments, the method provides receipts to confirm delivery ofmessages. In some embodiments, the method translates an identifier of anentity to a network address for delivery of a message to that entity.

In some embodiments, a method performed by a computing system fornotarizing a proposed transaction between parties is provided. Themethod receives from a second party a request to notarize an acceptedtransaction between a first party and the second party. The acceptedtransaction is proposed by the first party and signed by the first partyand the second party. The accepted transaction specifies a state thatincludes at least an input state or an output state and specifies anidentifier of the notary. The state has contract code for verifying thetransaction complies with terms of a contract. The method accesses aconsumed state storage to determine whether any input state has beenconsumed. When no input state has previously been consumed, the methodgenerates a notarized transaction by signing the proposed transaction,sends to the second party the notarized transaction, and stores in theconsumed state storage an indication that that any input state has beenconsumed. When an input state has previously been consumed, the methodnotifies the second party that the transaction cannot be notarized. Insome embodiments, the method verifies that the accepted transaction issigned by the first party and the second party.

In some embodiments, a method performed by a computing system forproviding a protocol framework to support protocol flows is provided.The method instantiates a protocol flow for execution. The methodverifies a proposed transaction that specifies state that includes atleast an input state or an output state and specifies an identifier of anotary. The state has contract code for verifying the proposedtransaction complies with terms of a contract. The verifying includesverifying that the proposed transaction is signed by an authorized partyand resolving the proposed transaction to ensure that the input state isvalid by executing the contract code of the state and transitivelyensuring that any input state is a valid output state of anothertransaction by executing contract code of the output state of the othertransaction. The method generates checkpoints during execution of theprotocol flow for restarting a protocol flow. In some embodiments, themethod coordinates the sending of and receiving of messages for theprotocol flow. In some embodiments, the method provides a mapping ofidentities of entities to addresses of nodes of the entities. In someembodiments, the method receives status update from the protocol andpublish the status updates. In some embodiments, the method invokes aschedule function of contact code of the output state of a notarizedtransaction to determine when a protocol flow for generating a proposedtransaction that inputs the output state is to be instantiated andexecuted.

In some embodiments, a method performed by a computing system isprovided to ensure deterministic operations of code executed by avirtual machine. The method modifies the code by instrumenting the codeso that execution of expensive operations are terminateddeterministically. The method modifies the code to disable catching ofcertain exceptions. The method modifies the code by relinking referencesof the code from standard functions of a standard runtime library toshadow functions of a shadow runtime library. The shadow functions aredeterministic versions of the standard functions. The method modifiesthe code to ensure that floating point operations are performeddeterministically. The method stores the modified code for subsequentexecution by the virtual machine.

Although the subject matter has been described in language specific tostructural features and/or acts, it is to be understood that the subjectmatter defined in the appended claims is not necessarily limited to thespecific features or acts described above. Rather, the specific featuresand acts described above are disclosed as example forms of implementingthe claims. Accordingly, the invention is not limited except as by theappended claims.

1. A computing system for providing a protocol framework to supportprotocol flows, the computing system comprising: one or morecomputer-readable storage mediums for storing computer-executableinstructions for controlling the computing system to: instantiate aprotocol flow for execution; and verify a proposed transaction is valid,the proposed transaction specifying state that includes a first inputstate and a first output state, the state having contract code, theverifying including: verifying that the proposed transaction is signedvia a computing node of an authorized party; and resolving the proposedtransaction by executing the contract code to determine whether thefirst input state and the first output state are valid and by ensuringthat the first input state is an output state of a second transactionthat is valid; and one or more processors for executing thecomputer-executable instructions stored in the one or morecomputer-readable storage mediums.
 2. The computing system of claim 1wherein the instructions control the computing system to ensure thefirst input state is valid output state of the second transaction byexecuting contract code of the output state of the second transaction.3. The computing system of claim 2 wherein ensuring that the first inputstate is valid output state of the second transaction comprisestransitively ensuring that an input state of the second transaction isvalid output of a third transaction.
 4. The computing system of claim 1wherein the instructions control the computing system to generatecheckpoints during execution of the protocol flow for restarting theprotocol flow.
 5. The computing system of claim 1 wherein theinstructions control the computing system to coordinate sending andreceiving messages for the protocol flow.
 6. The computing system ofclaim 1 wherein the instructions control the computing system to providea mapping of identities of entities to addresses of nodes of theentities.
 7. The computing system of claim 1 wherein the instructionscontrol the computing system to receive status update from the protocoland publish the status updates.
 8. The computing system of claim 1wherein the instructions control the computing system to invoke aschedule function of contract code of the output state of a transactionto determine when a protocol flow for generating a proposed transactionthat inputs the output state is to be executed.
 9. The computing systemof claim 1 wherein the instructions control the computing system torewrite a protocol flow so that the protocol flow is resumable.
 10. Thecomputing system of claim 1 wherein the instructions control thecomputing system to submit the proposed transaction to a notarycomputing node to determine whether an output state of a secondtransaction has been consumed.
 11. The computing system of claim 1wherein the instructions control the computing system to ensure that thecontract code executes deterministically.
 12. The computing system ofclaim 1 wherein the instructions control the computing system to rewritethe contract code by performing one or more of checking for forbiddenconstructs, instrumenting expensive bytecodes, disabling forbiddenexception caching, relinking references in constant pool, and ensuringdeterministic floating-point operation.
 13. A computing system forproviding a protocol framework to support protocol flows, the computingsystem comprising: one or more computer-readable storage mediums forstoring computer-executable instructions; a component to instantiate aprotocol flow for execution; a component to verify that a proposedtransaction is valid by verifying that the proposed transaction issigned via a computing node of an authorized party and resolving theproposed transaction by executing contract code of the proposedtransaction and ensuring that an input state is valid output state of asecond transaction that is valid; and a component to ensure that thecontract code executes deterministically; and one or more processors forexecuting the computer-executable instructions stored in the one or morecomputer-readable storage mediums.
 14. The computing system of claim 13wherein the ensuring that the input state is valid output state of thesecond transaction comprises executing contract code of an output stateof the second transaction.
 15. The computing system of claim 14 whereinthe ensuring transitively ensures that the input state of the secondtransaction is valid output state of a third transaction.
 16. Thecomputing system of claim 13 wherein the computer-executableinstructions further include a component to generate checkpoints duringexecution of the protocol flow for restarting the protocol flow.
 17. Thecomputing system of claim 13 wherein the computer-executableinstructions further include a component to coordinate sending andreceiving messages for the protocol flow.
 18. The computing system ofclaim 13 wherein the computer-executable instructions further include acomponent to map identities of entities to addresses of nodes of theentities.
 19. The computing system of claim 13 wherein thecomputer-executable instructions further include a component to receivea status update from the protocol and publish the status update.
 20. Thecomputing system of claim 13 wherein the computer-executableinstructions further include a component to invoke a schedule functionof contract code of output state of a transaction to determine when aprotocol flow for generating a proposed transaction that inputs theoutput state is to be instantiated and executed.
 21. The computingsystem of claim 13 wherein the computer-executable instructions furtherinclude a component to rewrite a protocol flow so that the protocol flowis resumable.
 22. The computing system of claim 21 wherein the rewrittenprotocol flow implements a resumable state machine.
 23. The computingsystem of claim 13 wherein the computer-executable instructions furtherinclude a component to rewrite the contract code by performing one ormore of checking for forbidden constructs, instrumenting expensivebytecodes, disabling forbidden exception caching, relinking referencesin constant pool, and ensuring deterministic floating-point operation.24. A method comprising: receiving, via a computing node of adistributed ledger system, a proposed transaction that includes inputstate, output state, and contract code; ensuring that the contract codeexecutes deterministically; verifying that the proposed transaction issigned by an authorized party; resolving the proposed transaction byexecuting the contract code of the proposed transaction and ensuringthat a first input state is a valid output state of a second transactionthat is valid; and submitting the proposed transaction to a notarycomputing node to verify that the output state of the second transactionhas not be consumed.
 25. The method of claim 24 further comprisingensuring that the contract code executes deterministically.
 26. Themethod of claim 24 further comprising executing contract code of theoutput state of the second transaction to determine whether the outputstate of the second transaction is valid.
 27. The method of claim 24further comprising generating checkpoints during execution of a protocolflow associated with the computing node for restarting the protocolflow.
 28. The method of claim 24 further comprising invoking contractcode to determine when a protocol flow for generating a proposedtransaction that inputs the output state of the proposed transaction tobe executed.
 29. The method of claim 24 further comprising rewriting aprotocol flow so that the protocol flow is resumable.